package com.kqb.controller;

import com.kqb.common.domain.AjaxResult;
import com.kqb.pojo.Dict;
import com.kqb.pojo.Product;
import com.kqb.pojo.dto.ProductDto;
import com.kqb.service.IProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杉果树皮
 * @date 2025/3/3 19:43
 * @description: 产品
 */
@RequestMapping("/api")
@Api(tags = "产品")
@RestController
public class ProductController {
    @Autowired
    private IProductService iProductService;

    @PostMapping("/product")
    @ApiOperation("添加产品")
    public AjaxResult save(@RequestBody Product product) {
        return iProductService.save(product);
    }

    @GetMapping("/product")
    @ApiOperation("根据条件")
    public AjaxResult selectByPage(ProductDto productDto) {
        return iProductService.selectByPage(productDto);
    }

    @DeleteMapping("/product/{id}")
    @ApiOperation("删除产品")
    public AjaxResult deleteById(@PathVariable("id") Integer id) {
        return iProductService.deleteById(id);
    }

    @PutMapping("/product")
    @ApiOperation("修改产品信息")
    public AjaxResult update(@RequestBody Product product) {
        return iProductService.updateProductById(product);
    }

}
